return view.extend({
- render(data) {
+ load() {
+ return fs.exec_direct('/usr/sbin/chronyd', ['-v']).then(output => {
+ const flags = ['IPv6', 'NTP', 'NTS', 'RTC'];
+ const features = Object.fromEntries(
+ flags.map(flag => [flag.toLowerCase(), output.includes(`+${flag}`)])
+ );
+
+ return features;
+ });
+ },
+
+ render(features) {
const docUrl = 'https://chrony-project.org/documentation.html';
let m, s, o;
o.nocreate = true;
o.rmempty = false;
- // NTS
- s = m.section(form.NamedSection, 'nts', 'nts', _('Network Time Security (NTS)'));
- s.anonymous = true;
- s.addremove = true;
+ if (features.nts) {
+ // NTS
+ s = m.section(form.NamedSection, 'nts', 'nts', _('Network Time Security (NTS)'));
+ s.anonymous = true;
+ s.addremove = true;
- o = s.option(form.Flag, 'rtccheck', _('RTC Check'),
- _('Check for the presence of %s.'.format('<code>/dev/rtc0</code>'), 'Check for RTC character device') + '<br/>' +
- _('Disables certificate time checks via %s if RTC is absent.'.format('<code>nocerttimecheck</code>') ) );
- o.default = o.disabled;
+ o = s.option(form.Flag, 'rtccheck', _('RTC Check'),
+ _('Check for the presence of %s.'.format('<code>/dev/rtc0</code>'), 'Check for RTC character device') + '<br/>' +
+ _('Disables certificate time checks via %s if RTC is absent.'.format('<code>nocerttimecheck</code>') ) );
+ o.default = o.disabled;
- o = s.option(form.Flag, 'systemcerts', _('Use system CA bundle'));
- o.default = o.enabled;
+ o = s.option(form.Flag, 'systemcerts', _('Use system CA bundle'));
+ o.default = o.enabled;
- o = s.option(form.FileUpload, 'trustedcerts', _('Trusted certificates'));
- o.optional = true;
- o.root_directory = '/etc';
+ o = s.option(form.FileUpload, 'trustedcerts', _('Trusted certificates'));
+ o.optional = true;
+ o.root_directory = '/etc';
+ }
// Stepping
s = m.section(form.NamedSection, 'makestep', 'makestep', _('Stepping'),
_('Remote NTP servers for your chronyd'));
s.anonymous = true;
s.addremove = true;
- insertTypedSectionOptions(m, s, o, 'server');
+ insertTypedSectionOptions(m, s, o, 'server', features);
// Pool entries
s = m.section(form.TypedSection, 'pool', _('Pool'),
_('The pool name is expected to resolve to multiple addresses which might change over time.'));
s.anonymous = true;
s.addremove = true;
- insertTypedSectionOptions(m, s, o, 'pool');
+ insertTypedSectionOptions(m, s, o, 'pool', features);
// Peer entries
s = m.section(form.TypedSection, 'peer', _('Peer'),
_('A single symmetric association allows the peers to be both servers and clients to each other.'));
s.anonymous = true;
s.addremove = true;
- insertTypedSectionOptions(m, s, o, 'peer');
+ insertTypedSectionOptions(m, s, o, 'peer', features);
// Servers assigned (to us) via DHCP
s = m.section(form.NamedSection, 'dhcp_ntp_server', 'dhcp_ntp_server', _('DHCP(v6)'),
_('Options for servers provided to this host via DHCP(v6) (via the WAN for example).'));
s.anonymous = true;
- insertTypedSectionOptions(m, s, o, 'dhcp_ntp_server');
+ insertTypedSectionOptions(m, s, o, 'dhcp_ntp_server', features);
return m.render();
}
});
-function insertTypedSectionOptions(m, s, o, type) {
+function insertTypedSectionOptions(m, s, o, type, features) {
o = s.option(form.Flag, 'disabled', _('Disabled'));
o.default = o.disabled; // disabled default is disabled i.e., enabled
o.default = o.disabled
o.depends('disabled', '0');
- o = s.option(form.Flag, 'nts', _('NTS'));
- o.rmempty = true;
- o.default = o.disabled
- o.depends('disabled', '0');
+ if (features.nts) {
+ o = s.option(form.Flag, 'nts', _('NTS'));
+ o.rmempty = true;
+ o.default = o.disabled
+ o.depends('disabled', '0');
+ }
}
o = s.option(form.Flag, 'prefer', _('Prefer'));